package com.syj.collect.base;

import android.content.Context;
import android.os.Bundle;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.amap.api.location.AMapLocation;
import com.syj.collect.entry.AllFragmentBean;
import com.syj.collect.utils.LoadingDialog;
import com.syj.collect.utils.LogUtils;

/**
 * @description fragment 基类
 */

public abstract class BaseFragment<T> extends Fragment {

    public static final String TAG = "okgo";
    protected BaseActivity mActivity;
    public LoadingDialog loadingDialog;
    /**
     * Fragment当前状态是否可见
     */
    protected boolean isVisible;

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (getUserVisibleHint()) {
            isVisible = true;
            onVisible();
        } else {
            isVisible = false;
            onInvisible();
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mActivity = (BaseActivity) context;
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(getLayoutId(), container, false);
        loadingDialog = new LoadingDialog(getActivity());
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        loadingDialog.dismiss();

    }

    protected abstract int getLayoutId();


    /**
     * 可见时的回调方法
     */
    protected void onVisible() {
    }

    /**
     * 不可见时的回调方法
     */
    protected void onInvisible() {
    }





}
